package com.googlecode.accurev2disk;

public class AccurevTVersion {

	String path;
	String eid;
	String virtual
	String real
	String virtualNamedVersion
	String realNamedVersion
	String elem_type
	String dir
	



	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	def String toString(){
		String text = "Path: ${path}\r\nElement-ID: ${eid}\r\nVirtual: ${virtual}\r\nReal: ${real}\r\nVirtualNamedVersion: ${virtualNamedVersion}\r\nrealNamedVersion: ${realNamedVersion}\r\nElement-Type: ${elem_type}\r\nDir: ${dir}\r\n"
		return text
	}

	/**
	 * Returns the status of this Version in the given Stream
	 * @param stream The Stream for what the status shall be shown
	 * @return the status of the element in the Stream (return of 'accurev stat -s Stream this.path')
	 */
	public String stat(AccurevStream stream){

		String text
		String err
		
		def stat = "accurev stat -s ${stream.name} ${this.path}"
		def proc = stat.execute()
            
			err = proc.getErr()
			text = proc.getText()

			if(proc.waitFor() != 0) {

				println "failed calculating stat for ${virtualNamedVersion}. reason: ${err}"
			}
			return text
		
	}

}
